<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script>
			// 将相同的值相邻，然后遍历去除重复值 
			function unique(array){ 
			array.sort(); 
			var re=[array[0]]; 
			for(var i = 1; i < array.length; i++){ 
			if( array[i] !== re[re.length-1]){ 
				  re.push(array[i]); 
				 } 
			  } 
			   return re; 
			} 
			alert(unique([1,2,5,3,8,6,2,4]))
		</script>
	</body>
</html>
